/************************************************************************/
// Copyright (C) 2016, han_gangbiao. All rights reserved.
// Use of this source code is governed by a GPL-v2 license that can be found in the License file.
// 
// [Time]:      2016-1-4 21:53:17
// [Author]:    han_gangbiao [http://my.oschina.net/jackhen]
// [Info]:      
/************************************************************************/

#ifndef INCLUDE_NET_NETINSIDE_NETDATA_H_
#define INCLUDE_NET_NETINSIDE_NETDATA_H_

#include "base/baseheader.h"

class netdata_t
{
public:
	netdata_t();
	netdata_t( const char* data, int len );
	~netdata_t();

	inline bool empty() const { return m_len == 0; }
	inline const char* c_str() const { return m_data; }
	inline int length() const { return m_len; }
	inline int capacity() const { return m_cap; }

public:
	int reserve( int len );
	inline netdata_t& assign( const netdata_t& nd ) { return assign( nd.c_str(), nd.length() ); }
 	netdata_t& assign( const char* data, int len );
	inline netdata_t& operator= ( const netdata_t& nd ) { return assign(nd); }

	inline netdata_t& append( const netdata_t& nd ) { return append( nd.c_str(), nd.length() ); }
	netdata_t& append( const char* data, int len );
	inline netdata_t& operator+= ( const netdata_t& nd ) { return append(nd); }

protected:
	char* m_data;
	int m_len;
	int m_cap;
};

#endif //~INCLUDE_NET_NETINSIDE_NETDATA_H_
